package com.dangdang.ddframe.job.spring.namespace.parser.simple;


import com.dangdang.ddframe.job.api.listener.ElasticJobListener;
import com.dangdang.ddframe.job.spring.schedule.SpringJobScheduler;
import com.dangdang.ddframe.reg.spring.namespace.SpringZookeeperRegistryCenter;
import com.ziroom.busrecoup.elasticjob.SimpleJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * 描述:
 * elastic job配置
 *
 * @author Yangjy
 * @date 2018-03-26
 */
@Configuration
@PropertySource("classpath:zk_config.properties")
public class SimpleJobConfiguration {


    @Autowired
    private SpringZookeeperRegistryCenter regCenter;

    @Bean(initMethod = "init")
    public SpringJobScheduler springJobScheduler(@Autowired SpringZookeeperRegistryCenter springZookeeperRegistryCenter) {
        SimpleJobConfigurationDto simpleJobConfigurationDto = new SimpleJobConfigurationDto("busRecoupJob", SimpleJob.class, 10, "0/10 * * * * ?");
        SpringJobScheduler springJobScheduler = new SpringJobScheduler(springZookeeperRegistryCenter, simpleJobConfigurationDto, new ElasticJobListener[0]);
        return springJobScheduler;
    }


    @Bean(name = "busRecoupJob", initMethod = "init")
    public SpringJobScheduler busRecoupJob() {
        SimpleJobConfigurationDto job = new SimpleJobConfigurationDto(
                "busRecoupJob", SimpleJob.class, 10, "0 0/10 * * * ?");
        return new SpringJobScheduler(regCenter, job);
    }

}
